<?php
class Admincpanel_PublicController extends Zendvn_Controller_Action{
	
	//Mang tham so nhan duoc o moi Action
	protected $_arrParam;
	
	public function init()
	{
		//Mang tham so nhan duoc o moi Action
		$this->_arrParam = $this->_request->getParams();
		
		//Truyen ra view
		$this->view->base_url = APPLICATION_URL;
	}
	
	public function noAccessAction()
	{
		$this->_helper->viewRenderer('error');
	}
	
	public function loginAction()
	{
	}
	
	public function authAction()
	{
		if ($this->_request->isPost())
		{
			$ns = new Zend_Session_Namespace('captcha');
			if ($ns->code != $this->_arrParam['captcha'])
			{
				$this->view->auth_status = 'InvalidCaptcha';	
			}
			else
			{
				$auth = new Zendvn_System_Auth();
				if ($auth->login($this->_arrParam))
				{
					$info = new Zendvn_System_Info();
					$info->createInfo();
					$this->view->auth_status = 'ok';
				}
				else
				{
					$this->view->auth_status = $auth->getError();
				}
			}
		}
	}
	
	public function logoutAction()
	{
		$auth = new Zendvn_System_Auth();
		$auth->logout();
		$info = new Zendvn_System_Info();
		$info->destroyInfo();
	}
	
	public function passRecoverAction()
	{
	}
}